# -*- coding: utf-8 -*-
# @File     : serializers.py
# @Author   : bingjia
# @Time     : 2020/8/11 10:32
# @Desc     :

from operation.base.api import serializers

from . import models


class InfoSerializer(serializers.ModelSerializer):
    """
    信息序列化
    """
    type = serializers.SerializerMethodField()
    attachment = serializers.SerializerMethodField()

    class Meta:
        model = models.Info
        fields = ['id', 'type', 'title', 'content', 'attachment']

    def get_type(self, obj):
        return obj.get_type_display()

    def get_attachment(self, obj):
        return obj.attachment


